package com.canin.util;

import java.sql.Date;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.canin.Constant;
import com.canin.dao.BreedDAO;
import com.canin.dao.DAOFactory;
import com.canin.dao.DogDAO;
import com.canin.model.Breed;
import com.canin.model.DietWeek;
import com.canin.model.Dog;
import com.canin.model.Food;

public class CaninUtil
{
	public static Map<String, String> retrieveBreedNameList() throws Exception
	{
		ArrayList<Breed> breedList = new ArrayList<Breed>();

		DAOFactory daoFactory = new DAOFactory();
		daoFactory.beginConnection();

		BreedDAO breedDAO = daoFactory.createBreedDAO();
		breedList = breedDAO.getBreedName();
		
		TreeMap<String, String> nameList = new TreeMap<>();
		for ( Breed breed : breedList )
		{
			nameList.put( Integer.toString( breed.getBreedId() ), breed.getBreedName() );
		}
		
		return nameList;
	}
	
	public static Map<String, String> retrieveDogNameList( int memberId ) throws Exception
	{
//		member = (Member)userSession.get( Constant.MEMBER );
		ArrayList<Dog> dogNameList = new ArrayList<Dog>();
		TreeMap<String, String> dogNameMap = new TreeMap<>();

		DAOFactory daoFactory = new DAOFactory();
		daoFactory.beginConnection();

		DogDAO dogDAO = daoFactory.createDogDAO();
		dogNameList = dogDAO.getDogNameList( memberId );
//		dogNameList = dogDAO.getDogNameList( member.getMemberId() );
		
		for ( Dog dog : dogNameList )
		{
			dogNameMap.put( Integer.toString( dog.getDogStaticId() ), dog.getDogName() );
		}
		
		return dogNameMap;
	}
	
	@SuppressWarnings("deprecation")
	public static String generateDateCount( Date updatedDate )
	{
//		java.util.Date dt = new java.util.Date();
		java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy");
//		java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//		String currentTime = sdf.format(dt);
		
		String dateDisplay = "ข้อมูลถูกปรับปรุงล่าสุด เมื่อวันที่ ";
		dateDisplay = dateDisplay + sdf.format( updatedDate );
		
		int dayCount = 0;
		
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
//		int thaiYear = year + 543;
		int month = cal.get(Calendar.MONTH);
		int day = cal.get(Calendar.DATE);
		
		int udYear = updatedDate.getYear() + 1900;
		int udMonth = updatedDate.getMonth();
		int udDate = updatedDate.getDate();
		
//		System.out.println("\n\n");
//		System.out.println("thaiYear: " + year + " updateYear: " + udYear);
//		System.out.println("month: " + month + " udMonth: " + udMonth);
//		System.out.println("day: " + day + " udDate: " + udDate);
//		System.out.println("\n\n");
		
		if ( year > udYear ){
			dayCount += ( year - udYear ) * 365; 
		}
		
		if ( month > udMonth ){
			dayCount += ( month - udMonth ) * 30;
		}
		
		if ( day > udDate ){
			dayCount += ( day - udDate );
		}
		
		dateDisplay = dateDisplay + ", " + dayCount + " วัน ที่ผ่านมา";
		
		return dateDisplay;
	}
	
	/**
	 * 
	 * @param yearOfBirth dog's year of birth
	 * @param monthOfBirth
	 * @return
	 */
	public static String calAge( int yearOfBirth, int monthOfBirth )
	{
		String age = "";
		
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
		int thaiYear = year + 543;
		int month = cal.get(Calendar.MONTH);
		
		if ( thaiYear != yearOfBirth ){
			age = ( thaiYear - yearOfBirth ) + " ปี ";
		}
		
		if ( month != monthOfBirth ){
			age = age + ( month - monthOfBirth ) + " เดือน";
		}
		
		return age;
	}
	
	public static String calLifeSpan( int yearOfBirth, int monthOfBirth, int pregnantWeeks, int lactateWeeks, 
			int breedId ) throws Exception
	{
		String lifeSpan ="";
		
		Calendar cal = Calendar.getInstance();
		int year = cal.get(Calendar.YEAR);
		int thaiYear = year + 543;
		int month = cal.get(Calendar.MONTH);
		
		int age_y = thaiYear - yearOfBirth;
		int age_m = month - monthOfBirth;
		
		DAOFactory daoFactory = new DAOFactory();
		daoFactory.beginConnection();
		BreedDAO breedDAO = daoFactory.createBreedDAO();
		Breed breed = breedDAO.getBreedById( breedId );
		
		if ( pregnantWeeks > 0 )
		{
			lifeSpan = "วัยแม่สุนัข กำลังตั้งท้อง";
		}
		else if ( lactateWeeks > 0 )
		{
			lifeSpan = "วัยแม่สุนัข กำลังให้นม";
		}
		else if ( age_y < breed.getAdultMinAgeYear()
			|| ( age_y == breed.getAdultMinAgeYear() && age_m < breed.getAdultMinAgeMonth() ) )
		{
			lifeSpan = "วัยลูกสุนัข";
		}
		else if ( age_y == breed.getAdultMinAgeYear()
			&& age_m > breed.getAdultMinAgeMonth() )
		{
			lifeSpan = "วัยโตเต็มวัย";
		}
		else if ( age_y > breed.getAdultMinAgeYear()
			&& age_y < breed.getSeniorMinAgeYear() )
		{
			lifeSpan = "วัยโตเต็มวัย";
		}
		else if ( age_y == breed.getSeniorMinAgeYear()
			&& age_m < breed.getSeniorMinAgeMonth() )
		{
			lifeSpan = "วัยโตเต็มวัย";
		}
		else if ( age_y >= breed.getSeniorMinAgeYear() )
		{
			lifeSpan = "วัยชรา";
		}
		
		return lifeSpan;
	}
	
	public static String changeLifeSpanThaiToEng( String thaiLifeSpan )
	{
		String engLifeSpan = "";
		
		if ( "วัยแม่สุนัข กำลังตั้งท้อง".equals( thaiLifeSpan ) )
		{
			engLifeSpan = "Pregnant";
		}
		else if ( "วัยแม่สุนัข กำลังให้นม".equals( thaiLifeSpan ) )
		{
			engLifeSpan = "Lactate";
		}
		else if ( "วัยลูกสุนัข".equals( thaiLifeSpan ) )
		{
			engLifeSpan = "Puppy";
		}
		else if ( "วัยโตเต็มวัย".equals( thaiLifeSpan ) )
		{
			engLifeSpan = "Adult";
		}
		else if ( "วัยชรา".equals( thaiLifeSpan ) )
		{
			engLifeSpan = "Senior";
		}
		
		return engLifeSpan;
	}
	
	public static String getBreedNameByBreedId( int breedId ) throws Exception
	{
		Breed breed = new Breed();
		
		DAOFactory daoFactory = new DAOFactory();
		daoFactory.beginConnection();

		BreedDAO breedDAO = daoFactory.createBreedDAO();
		breed = breedDAO.getBreedById( breedId );
		
		return breed.getBreedName();
	}
	
	public static String getBreedSizeByBreedId( int breedId ) throws Exception
	{
		Breed breed = new Breed();
		
		DAOFactory daoFactory = new DAOFactory();
		daoFactory.beginConnection();

		BreedDAO breedDAO = daoFactory.createBreedDAO();
		breed = breedDAO.getBreedById( breedId );
		
		return breed.getSize();
	}
	
	/**
	 * @return 
	 * arraylist-0 - min weight
	 * arraylist-1 - max weight
	 */
	public static ArrayList<Integer> getBreedStandardWeightByBreedId( int breedId ) throws Exception
	{
		ArrayList<Integer> standardWeight = new ArrayList<Integer>();
		Breed breed = new Breed();
		
		DAOFactory daoFactory = new DAOFactory();
		daoFactory.beginConnection();

		BreedDAO breedDAO = daoFactory.createBreedDAO();
		breed = breedDAO.getBreedById( breedId );
		
		standardWeight.add(0, breed.getMinWeight());
		standardWeight.add(1, breed.getMaxWeight());
		
		return standardWeight;
	}
	
	public static Double round2decimal( Double value )
	{
		DecimalFormat df2 = new DecimalFormat("###.##");
        
		return Double.valueOf(df2.format(value));
	}
	
	public static Double calcDogCalloriesPerDay( String dogLifeSpan, Dog dog ) throws Exception
	{
		Double calPerday = 0.0;
		Double dogWeight = (double)dog.getDogWeight();
		
		if ( "Pregnant".equals( dogLifeSpan ) )
		{
			if ( dog.getPregnantWeeks() == 6 )
			{
//				110 x (น้ำหนัก)0.75 x 1.1
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.1 );
			}
			else if ( dog.getPregnantWeeks() == 7 )
			{
//				110 x (น้ำหนัก)0.75 x 1.2
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.2 );
			}
			else if ( dog.getPregnantWeeks() == 8 )
			{
//				110 x (น้ำหนัก)0.75 x 1.4
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.4 );
			}
			else if ( dog.getPregnantWeeks() == 9 )
			{
//				110 x (น้ำหนัก)0.75 x 1.6
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.6 );
			}
			else if ( dog.getPregnantWeeks() == 1
				|| dog.getPregnantWeeks() == 2
				|| dog.getPregnantWeeks() == 3
				|| dog.getPregnantWeeks() == 4
				|| dog.getPregnantWeeks() == 5 )
			{
//				110 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) );
			}
		}
		else if ( "Lactate".equals( dogLifeSpan ) )
		{
			if ( dog.getLactateWeeks() == 1 )
			{
//				110 x (น้ำหนัก)0.75 x 1.5
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.5 );
			}
			else if ( dog.getLactateWeeks() == 2 )
			{
//				110 x (น้ำหนัก)0.75 x 2
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 2 );
			}
			else if ( dog.getLactateWeeks() == 3 )
			{
//				110 x (น้ำหนัก)0.75 x 3
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 3 );
			}
			else if ( dog.getLactateWeeks() == 4 )
			{
//				110 x (น้ำหนัก)0.75 x 4
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 4 );
			}
		}
		else if ( "Puppy".equals( dogLifeSpan )   )
		{
			DAOFactory daoFactory = new DAOFactory();
			daoFactory.beginConnection();
			BreedDAO breedDAO = daoFactory.createBreedDAO();
			Breed breed = breedDAO.getBreedById( dog.getBreedId() );
			double averageWeightBreed = ( breed.getMinWeight() + breed.getMaxWeight() )/2;
			double adultWeightPercent = ( dogWeight/averageWeightBreed )*100;
			
			if ( adultWeightPercent < 50.00 )
			{
//				110 x (น้ำหนัก)0.75 x 3
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 3 );
			}
			else if ( adultWeightPercent < 80.00 )
			{
//				110 x (น้ำหนัก)0.75 x 1.6
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.6 );
			}
			else
			{
//				110 x (น้ำหนัก)0.75 x 1.2
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.2 );
			}
		}
		else if ( "Adult".equals( dogLifeSpan ) )
		{
			if ( dog.getActivityLevel() == 1 )
			{
//				110 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) );
			}
			else if ( dog.getActivityLevel() == 2 )
			{
//				125 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 125*(Math.pow( dogWeight, 0.75)) );
			}
			else if ( dog.getActivityLevel() == 3 )
			{
//				175 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 175*(Math.pow( dogWeight, 0.75)) );
			}
		}
		else if ( "Senior".equals( dogLifeSpan )   )
		{
//			90 x (น้ำหนัก)0.75
			calPerday = CaninUtil.round2decimal( 90*(Math.pow( dogWeight, 0.75)) );
		}
		
		return calPerday;
	}
	
	public static Double calcDogCalloriesPerDay( String dogLifeSpan, Dog dog, Double dogWeight ) throws Exception
	{
		Double calPerday = 0.0;
		
		if ( "Pregnant".equals( dogLifeSpan ) )
		{
			if ( dog.getPregnantWeeks() == 6 )
			{
//				110 x (น้ำหนัก)0.75 x 1.1
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.1 );
			}
			else if ( dog.getPregnantWeeks() == 7 )
			{
//				110 x (น้ำหนัก)0.75 x 1.2
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.2 );
			}
			else if ( dog.getPregnantWeeks() == 8 )
			{
//				110 x (น้ำหนัก)0.75 x 1.4
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.4 );
			}
			else if ( dog.getPregnantWeeks() == 9 )
			{
//				110 x (น้ำหนัก)0.75 x 1.6
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.6 );
			}
			else if ( dog.getPregnantWeeks() == 1
				|| dog.getPregnantWeeks() == 2
				|| dog.getPregnantWeeks() == 3
				|| dog.getPregnantWeeks() == 4
				|| dog.getPregnantWeeks() == 5 )
			{
//				110 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) );
			}
		}
		else if ( "Lactate".equals( dogLifeSpan ) )
		{
			if ( dog.getLactateWeeks() == 1 )
			{
//				110 x (น้ำหนัก)0.75 x 1.5
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.5 );
			}
			else if ( dog.getLactateWeeks() == 2 )
			{
//				110 x (น้ำหนัก)0.75 x 2
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 2 );
			}
			else if ( dog.getLactateWeeks() == 3 )
			{
//				110 x (น้ำหนัก)0.75 x 3
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 3 );
			}
			else if ( dog.getLactateWeeks() == 4 )
			{
//				110 x (น้ำหนัก)0.75 x 4
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 4 );
			}
		}
		else if ( "Puppy".equals( dogLifeSpan )   )
		{
			DAOFactory daoFactory = new DAOFactory();
			daoFactory.beginConnection();
			BreedDAO breedDAO = daoFactory.createBreedDAO();
			Breed breed = breedDAO.getBreedById( dog.getBreedId() );
			double averageWeightBreed = ( breed.getMinWeight() + breed.getMaxWeight() )/2;
			double adultWeightPercent = ( dogWeight/averageWeightBreed )*100;
			
			if ( adultWeightPercent < 50.00 )
			{
//				110 x (น้ำหนัก)0.75 x 3
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 3 );
			}
			else if ( adultWeightPercent < 80.00 )
			{
//				110 x (น้ำหนัก)0.75 x 1.6
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.6 );
			}
			else
			{
//				110 x (น้ำหนัก)0.75 x 1.2
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) * 1.2 );
			}
		}
		else if ( "Adult".equals( dogLifeSpan ) )
		{
			if ( dog.getActivityLevel() == 1 )
			{
//				110 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 110*(Math.pow( dogWeight, 0.75)) );
			}
			else if ( dog.getActivityLevel() == 2 )
			{
//				125 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 125*(Math.pow( dogWeight, 0.75)) );
			}
			else if ( dog.getActivityLevel() == 3 )
			{
//				175 x (น้ำหนัก)0.75
				calPerday = CaninUtil.round2decimal( 175*(Math.pow( dogWeight, 0.75)) );
			}
		}
		else if ( "Senior".equals( dogLifeSpan )   )
		{
//			90 x (น้ำหนัก)0.75
			calPerday = CaninUtil.round2decimal( 90*(Math.pow( dogWeight, 0.75)) );
		}
		
		return calPerday;
	}
	
	public static int getWeekToDiet( double dogWeight, double dogIdealWeight )
	{
		int weeks = 0;
		while( dogWeight >= dogIdealWeight )
		{
			weeks++;
			dogWeight = dogWeight - ( 0.015*dogWeight );
			dogWeight = round2decimal(dogWeight);
			System.out.println("==> dogWeight " + dogWeight);
		}
		
//		weeks--;
		System.out.println("==> Week " + weeks);
		
		return weeks;
	}
	
	public static List<Food> calcForDietWeek( List<Food> orderFoodList
			, Dog dog, double idealWeight ) throws Exception
	{
		for ( Food food : orderFoodList )
		{
			ArrayList<DietWeek> dietWeekList = new ArrayList<DietWeek>();
			double dogWeight = dog.getDogWeight();
			int weeks = 0;
	
			DietWeek dietWeek;
			while( dogWeight >= idealWeight )
			{
				weeks = weeks + 1;
				dietWeek = new DietWeek();
				
				dogWeight = dogWeight - ( 0.015*dogWeight );
				dogWeight = round2decimal(dogWeight);
				String dogLifeSpan =  calLifeSpan( dog.getYearOfBirth(),
						dog.getMonthOfBirth(), dog.getPregnantWeeks(), 
						dog.getLactateWeeks(), dog.getBreedId() );
				dogLifeSpan = changeLifeSpanThaiToEng(dogLifeSpan);
				double dogCallPerDay = calcDogCalloriesPerDay(dogLifeSpan, dog, dogWeight);
				
				dietWeek.setWeek(weeks);
				dietWeek.setKiloPerWeek(dogWeight);
				ArrayList<Object> suggList = getsuggestPerDay( food, dogCallPerDay );
				dietWeek.setCups((int)suggList.get(0));
				dietWeek.setSub((int)suggList.get(1));
				String sugPD = setSuggestPerDay( getsuggestPerDay( food, dogCallPerDay ) );
				dietWeek.setSuggestPerDay( sugPD );
				
				dietWeekList.add( dietWeek );
			}
			
			food.setDietWeekList(dietWeekList);
		}
		
		return orderFoodList;
	}
	
	private static String setSuggestPerDay( ArrayList<Object> suggestArrayList )
	{
		int kilo = (Integer)suggestArrayList.get(2);
		double grams = (Double)suggestArrayList.get(3);
		
		String suggestPerDay = " หรือ ";
		if ( kilo != 0 ){
			suggestPerDay = suggestPerDay + kilo + " กิโลกรัม";
		}
		suggestPerDay = suggestPerDay + grams + " กรัม";
		
		return suggestPerDay;
	}
	
	/**
	 * 0- cups
	 * 1- sub
	 * 2- kilograms
	 * 3- grams
	 */
	public static ArrayList<Object> getsuggestPerDay( Food food, double dogCallPerDay )
	{
		ArrayList<Object> suggestArrayList = new ArrayList<Object>();
		int cup = 0;
		int kilo = 0;
		double grams = 0.0;
		int sub = 0;
		
		if ( food.getKilocalorie() != 0 )
		{
			double kiloCalPerDay = dogCallPerDay/food.getKilocalorie();
			double cupPerDay = (kiloCalPerDay*1000)/90;
			
			kilo = (int)kiloCalPerDay;
			grams = CaninUtil.round2decimal( (kiloCalPerDay*1000) - (kilo*1000) );
			
			cup = (int)cupPerDay;
			double cupFraction= cupPerDay - cup;
			
			if ( cupFraction <= 0.25 ){
				sub = 1;
			}else if ( cupFraction <= 0.50 ){
				sub = 2;
			}else if ( cupFraction <= 0.75 ){
				sub = 3;
			}else if ( cupFraction <= 1.00 ){
				cup = cup + 1;
			}
		}
		
		suggestArrayList.add(0, cup);
		suggestArrayList.add(1, sub);
		suggestArrayList.add(2, kilo);
		suggestArrayList.add(3, grams);
		
		return suggestArrayList;
	}
	
	/*
	 * 0- cups
	 * 1- sub
	 * 2- suggestPerDay
	 */
	public static List<Food> setQuantityPerDay( List<Food> orderFoodList, double dogCallPerDay )
	{
		for ( Food food : orderFoodList )
		{
			if ( food.getKilocalorie() != 0 )
			{
				double kiloCalPerDay = dogCallPerDay/food.getKilocalorie();
				double cupPerDay = (kiloCalPerDay*1000)/90;
				
				int kilo = (int)kiloCalPerDay;
				double grams = CaninUtil.round2decimal( (kiloCalPerDay*1000) - (kilo*1000) );
				
				int cup = (int)cupPerDay;
				double cupFraction= cupPerDay - cup;
				
				int sCup = 0;
				if ( cupFraction <= 0.25 ){
					sCup = 1;
				}else if ( cupFraction <= 0.50 ){
					sCup = 2;
				}else if ( cupFraction <= 0.75 ){
					sCup = 3;
				}else if ( cupFraction <= 1.00 ){
					cup = cup + 1;
				}
				
				String suggestPerDay = " หรือ ";
				if ( kilo != 0 ){
					suggestPerDay = suggestPerDay + kilo + " กิโลกรัม";
				}
				suggestPerDay = suggestPerDay + grams + " กรัม";
				
				food.setCups(cup);
				food.setSub(sCup);
				food.setSuggestPerDay( suggestPerDay );
			}
		}
		
		return orderFoodList;
	}
	
	public static Map<String, String> initializeSizes()
	{
		TreeMap<String, String> sizes = new TreeMap<String, String>();
		sizes.put(Constant.SIZE_SS, "เล็กมาก");
		sizes.put(Constant.SIZE_S, "เล็ก");
		sizes.put(Constant.SIZE_M, "กลาง");
		sizes.put(Constant.SIZE_L, "ใหญ่");
		sizes.put(Constant.SIZE_XL, "ใหญ่มาก");
		
		return sizes;
	}
	
	public static Map<String, String> initializeDogSizes()
	{
		TreeMap<String, String> sizes = new TreeMap<String, String>();
		sizes.put(Constant.SIZE_X_SMALL, "เล็กมาก");
		sizes.put(Constant.SIZE_SMALL, "เล็ก");
		sizes.put(Constant.SIZE_MEDIUM, "กลาง");
		sizes.put(Constant.SIZE_LARGE, "ใหญ่");
		sizes.put(Constant.SIZE_GIANT, "ใหญ่มาก");
		sizes.put(Constant.SIZE_ALL, "ทุกขนาด");
		
		return sizes;
	}
	
	public static Map<Integer, String> initializeNeckType()
	{
		TreeMap<Integer, String> sizes = new TreeMap<Integer, String>();
		sizes.put(Constant.COLLAR_NORMAL_SIZE, "คอปกติ");
		sizes.put(Constant.COLLAR_SLENDER_SIZE, "คอเรียวยาว");
		
		return sizes;
	}
	
	public static Map<String, String> initializeCollarSlender()
	{
		TreeMap<String, String> sizes = new TreeMap<String, String>();
		sizes.put(Constant.SIZE_SS, "เล็กมาก");
		sizes.put(Constant.SIZE_S, "เล็ก");
		sizes.put(Constant.SIZE_M, "กลาง");
		
		return sizes;
	}
	
	public static Map<Integer, String> initializeToyType()
	{
		TreeMap<Integer, String> sizes = new TreeMap<Integer, String>();
		sizes.put(Constant.TOY_TYPE_FRISBEE, "จานร่อน");
		sizes.put(Constant.TOY_TYPE_ROPETUGS, "เชือกชักเย่อ");
		sizes.put(Constant.TOY_TYPE_SUPPLYTUGS, "ห่วงชักเย่อ");
		sizes.put(Constant.TOY_TYPE_TOY, "ตุ๊กตา");
		sizes.put(Constant.TOY_TYPE_BALL, "ลูกบอล");
		sizes.put(Constant.TOY_TYPE_HIDDENFOODTHINGS, "ที่ซ่อนอาหาร");
		
		return sizes;
	}
	
	public static Map<String, String> initializeLifeSpan()
	{
		TreeMap<String, String> lifeSpan = new TreeMap<String, String>();
		lifeSpan.put(Constant.LIFE_SPAN_ADULT, "วัยโตเต็มวัย");
		lifeSpan.put(Constant.LIFE_SPAN_PUPPY, "วัยลูกสุนัข");
		lifeSpan.put(Constant.LIFE_SPAN_SENIOR, "วัยชรา");
		lifeSpan.put(Constant.LIFE_SPAN_PREGNANT, "วัยแม่สุนัข กำลังตั้งท้อง");
		lifeSpan.put(Constant.LIFE_SPAN_LACTATE, "วัยแม่สุนัข กำลังให้นม");
		
		return lifeSpan;
	}
	
	public static Map<String, String> initializeSizeCounts()
	{
		HashMap<String, String> lifeSpan = new HashMap<String, String>();
		lifeSpan.put(Constant.SIZE_COUNT_KILOGRAM, "กิโลกรัม");
		lifeSpan.put(Constant.SIZE_COUNT_GRAM, "กรัม");
		lifeSpan.put(Constant.SIZE_COUNT_ONZ, "ออนซ์");
		
		return lifeSpan;
	}
	
	public static Map<String, String> initializeSizeUnit()
	{
		HashMap<String, String> sizeUnit = new HashMap<String, String>();
		sizeUnit.put(Constant.SIZE_UNIT_CM, "ซม.");
		sizeUnit.put(Constant.SIZE_UNIT_INCH, "นิ้ว");
		
		return sizeUnit;
	}
	
	public static Map<String, String> initializeToothbrushType()
	{
		HashMap<String, String> sizeUnit = new HashMap<String, String>();
		sizeUnit.put(Constant.TOOTHBRUSH_TYPE_HANDLE, "แบบด้ามจับ");
		sizeUnit.put(Constant.TOOTHBRUSH_TYPE_PAW_FINGER, "แบบสวมนิ้ว");
		
		return sizeUnit;
	}
	
	public static Map<String, String> initializeFoodType()
	{
		HashMap<String, String> foodType = new HashMap<String, String>();
		foodType.put(Constant.FOOD_TYPE_DRY, "แห้ง");
		foodType.put(Constant.FOOD_TYPE_WET, "เปียก");
		
		return foodType;
	}
	
	public static Map<String, String> initializeSizeType()
	{
		HashMap<String, String> foodType = new HashMap<String, String>();
		foodType.put(Constant.SIZE_TYPE_KILOGRAMS, "กิโลกรัม");
		foodType.put(Constant.SIZE_TYPE_GRAMS, "กรัม");
		foodType.put(Constant.SIZE_TYPE_ONZ, "ออนซ์");
		
		return foodType;
	}
	
	public static Map<String, String> initializeCalType()
	{
		HashMap<String, String> foodType = new HashMap<String, String>();
		foodType.put(Constant.KILOCALORIES, "กิโลแคลอรี่");
		foodType.put(Constant.CALORIES_PER_CUP, "แคลอรี่ต่อถ้วย");
		foodType.put(Constant.CALORIES_PER_PACKAGE, "แคลอรี่ต่อหน่วยบรรจุภัณฑ์");
		
		return foodType;
	}
	
	public static Map<String, String> initializeCollarType()
	{
		HashMap<String, String> foodType = new HashMap<String, String>();
		foodType.put(Constant.COLLAR_TYPE_NORMAL, "ปลอกคอแบบธรรมดา");
		foodType.put(Constant.COLLAR_TYPE_SPECIAL, "ปลอกคอแบบพิเศษ");
		foodType.put(Constant.COLLAR_TYPE_ROLL, "ปลอกคอแบบม้วนกลม");
		
		return foodType;
	}
	
	public static Map<String, String> initializeCoatType()
	{
		HashMap<String, String> coatType = new HashMap<String, String>();
		coatType.put(Constant.COAT_0_ALL, "ขนทุกแบบ");
		coatType.put(Constant.COAT_1_SHORT_FLAT_POLISHED, "ขนสั้นและเรียบเป็นมันเงา");
		coatType.put(Constant.COAT_2_SHORT_THICK_WATERPROOF, "ขนสั้นและหนาช่วยกันน้ำ");
		coatType.put(Constant.COAT_3_WIRE_BROKEN, "ขนแข็งคล้ายเส้นลวด");
		coatType.put(Constant.COAT_4_SILK, "ขนคล้ายเส้นไหม");
		coatType.put(Constant.COAT_5_LONG, "ขนยาว");
		coatType.put(Constant.COAT_6_CURLY_NO_SHED, "ขนหยิกไม่ผลัดขน");
		
		return coatType;
	}
	
	public static String convertToConcurrency( int price, int decimal  )
	{
		String currency = "";
		String dec = ".0";
		if ( decimal == 2 ){
			dec =".00";
		}
		
		if ( price > 1000 )
		{
			int thousand = price/1000;
			thousand = (thousand*1000);
			
			int hundred = price-thousand;
			currency = String.valueOf(thousand/1000) + "," + String.valueOf(hundred) + dec;
			if(hundred==0){
				currency = String.valueOf(thousand/1000) + ",000" + dec;
			}
		}
		else
		{
			currency = String.valueOf(price) + dec;
		}
		
		return currency;
	}
	
	
	
	
	
	
}